
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Common
{
	public class Parser 
	{
		public static Command Parse (string xml)
		{
			Command c = new Command ();
			XDocument doc = XDocument.Parse (xml);
			c.Type = doc.Element("root").Element ("type").Value;
			c.Operation = doc.Element("root").Element ("operation").Value;
			foreach (XElement item in doc.Element("root").Element("commands").Elements()) {
				c.Commands.Add(new CommandItem(){ Name = item.Attribute("name").Value,
					Value = item.Attribute("value").Value});
			}

			return c;
		}
	}
}

